package com.wk.design.filterchain;

import java.util.ArrayList;
import java.util.List;

public class FilterChain {
	List<Filter> filters;
	int pos = 0;
	public FilterChain(){
		filters = new ArrayList<Filter>();
	}
	
	public void addFilter(Filter filter) {
		filters.add(filter);
	}
	public void doFilter(MyRequest req,MyResponse res) {
		if(pos<filters.size()) {
			filters.get(pos++).doFilter(req, res, this);
		}
		// handler
	}
	
}
